package configuration

import (
	"encoding/json"
	"errors"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

func init() {

	if err := json.Unmarshal(client.Load("ActivitySign"), &SignInConfigs); err != nil {
		panic(err)
	}

	log.Info("Load ActivitySign.json success.")

	//*****************************************************************************************//
}

var SignInConfigs []SignInConf

// 签到活动配置
type SignInConf struct {
	ID      int32 // 天数
	AwardID int32
}

func GetSignInConf(day int32) (SignInConf, error) {

	for _, v := range SignInConfigs {
		if v.ID == day {
			return v, nil
		}
	}

	return SignInConf{}, errors.New(fmt.Sprintf("SignInConf not found [%d]", day))
}
